﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AutoPlayMedia
{
    class Music
    {
        protected int _id;
        protected string _url;
        protected string _name;
        protected string _time;
        protected string _repeat;
        protected Dictionary<string, string> _dicTimeInDay = new Dictionary<string, string>(){
	        {"T2", ""},
	        {"T3", ""},
	        {"T4", ""},
	        {"T5", ""},
            {"T6", ""},
            {"T7", ""},
            {"CN", ""}
	    };

        public Music()
        {
            _id = -1;
            _url = "";
            _name = "";
            _time = "";
            _repeat = "";
            foreach (string key in _dicTimeInDay.Keys)
            {
                _dicTimeInDay[key] = "";
            }
        }
        public Music(int id, string url, string name, string time)
        {
            _id = id;
            _url = url;
            _name = name;
            _time = time;
            if (time != "")
            {
                string[] days = time.Split(';');
                if (days.Length > 0)
                {
                    foreach(string day in days)
                    {
                        string[] timeInDays = day.Split('#');
                        if (timeInDays.Length > 0)
                        {
                            if (_dicTimeInDay.ContainsKey(timeInDays[0]))
                            {
                                _dicTimeInDay[timeInDays[0]] = timeInDays[1];
                            }
                        }
                    }
                }
            }
        }
        public string PrintMusic()
        {
            return id.ToString() + "|" + url + "|" + name + "|" + time;

        }
        public int id
        {
            get
            {
                return _id;
            }
            set
            {
                _id = value;
            }
        }

        public string url
        {
            get
            {
                return _url;
            }
            set
            {
                _url = value;
            }
        }
        public string name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }
        public string time
        {
            get
            {
                return _time;
            }
            set
            {
                _time = value;
            }
        }
        public string repeat
        {
            get
            {
                return _repeat;
            }
            set
            {
                _repeat = value;
            }
        }
        public Dictionary<string, string> dicTimeInDay
        {
            get
            {
                return _dicTimeInDay;
            }
            set
            {
                _dicTimeInDay = value;
            }
        }
    }
}
